home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_inf_turnerhunt.cog < prev    next >
Text File  |  1999-11-15  |  15KB  |  409 lines

  1. # Jones 3D Cog Script
  2. #
  3. # INF_TurnerHunt.cog
  4. # Controls turner as he runs around the arena
  5. #
  6. # [SXC]
  7. #
  8. # (C) 1998 LucasArts Entertainment Co. All Rights Reserved
  9. # ========================================================================================
  10.  
  11. symbols
  12.  
  13.     message     startup
  14.     message     killed
  15.     message     user0
  16.     message     timer
  17.     message     aievent
  18.     message     damaged
  19.     
  20.     thing       player                                  local
  21.     
  22.     thing       turner                                  mask=0x408
  23.     
  24.     sound       tu_line0=im07t02.wav                    local
  25.     sound       tu_line1=im07t04.wav                    local
  26.     sound       tu_line2=im07t06.wav                    local
  27.     sound       tu_line3=im08t02.wav                    local
  28.     sound       tu_line4=im03t04.wav                    local
  29.     
  30.     template    imp2template=imp2                       local
  31.     
  32.     model          mod_tu_imp2=hand_tu_imp2_b.3do            local
  33.     
  34.     thing       dmatpoint0                              nolink
  35.     thing       dmatpoint1                              nolink
  36.     thing       dmatpoint2                              nolink
  37.     thing       dmatpoint3                              nolink
  38.     thing       dmatpoint4                              nolink 
  39.     thing       dmatpoint5                              nolink 
  40.     thing       dmatpoint6                              nolink 
  41.     thing       dmatpoint7                              nolink 
  42.     thing       dmatpoint8                              nolink 
  43.     thing       dmatpoint9                              nolink 
  44.     thing       dmatpoint10                             nolink 
  45.     thing       dmatpoint11                             nolink
  46.     thing       dmatpoint12                             nolink 
  47.     thing       dmatpoint13                             nolink 
  48.     thing       dmatpoint14                             nolink 
  49.     thing       dmatpoint15                             nolink
  50.     thing       dmatpoint16                             nolink 
  51.     thing       dmatpoint17                             nolink 
  52.     thing       dmatpoint18                             nolink 
  53.     thing       dmatpoint19                             nolink 
  54.     thing       dmatpoint20                             nolink 
  55.     thing       dmatpoint21                             nolink 
  56.     thing       dmatpoint22                             nolink 
  57.     thing       dmatpoint23                             nolink 
  58.     thing       dmatpoint24                             nolink 
  59.     thing       dmatpoint25                             nolink 
  60.     thing       dmatpoint26                             nolink 
  61.     thing       dmatpoint27                             nolink 
  62.     thing       dmatpoint28                             nolink 
  63.     thing       dmatpoint29                             nolink 
  64.     thing       dmatpoint30                             nolink 
  65.     thing       dmatpoint31                             nolink 
  66.     thing       dmatpoint32                             nolink 
  67.     thing       dmatpoint33                             nolink 
  68.     thing       dmatpoint34                             nolink 
  69.     thing       dmatpoint35                             nolink 
  70.     thing       dmatpoint36                             nolink 
  71.     thing       dmatpoint37                             nolink 
  72.     thing       dmatpoint38                             nolink 
  73.     thing       dmatpoint39                             nolink 
  74.     thing       dmatpoint40                             nolink 
  75.     thing       dmatpoint41                             nolink 
  76.     thing       dmatpoint42                             nolink 
  77.     thing       dmatpoint43                             nolink 
  78.     thing       dmatpoint44                             nolink 
  79.     thing       dmatpoint45                             nolink 
  80.     thing       dmatpoint46                             nolink 
  81.     thing       dmatpoint47                             nolink 
  82.     thing       dmatpoint48                             nolink 
  83.     thing       dmatpoint49                             nolink 
  84.     thing       dmatpoint50                             nolink 
  85.     thing       dmatpoint51                             nolink  
  86.     thing       dmatpoint52                             nolink 
  87.     thing       dmatpoint53                             nolink 
  88.     thing       dmatpoint54                             nolink 
  89.     thing       dmatpoint55                             nolink 
  90.     thing       dmatpoint56                             nolink 
  91.     thing       dmatpoint57                             nolink 
  92.     thing       dmatpoint58                             nolink 
  93.     thing       dmatpoint59                             nolink 
  94.     thing       dmatpoint60                             nolink 
  95.     thing       dmatpoint61                             nolink 
  96.     thing       dmatpoint62                             nolink 
  97.     thing       dmatpoint63                             nolink
  98.     
  99.     vector      player_curpos                           local
  100.     
  101.     flex        curdist                                 local
  102.     flex        dist_index                              local
  103.     flex        cur_smallest                            local
  104.     flex        next_smallest                           local
  105.     
  106.     int         loc_index                               local
  107.     int         fleeindex                               local
  108.                                                         
  109.     int         arraycount=0                            local
  110.                                                         
  111.     int         modenum=0                               local
  112.     int         lastrand=-1                             local
  113.     int         currand=0                               local
  114.     int         lastrandt=-1                            local
  115.     int         currandt=0                              local
  116.     int         lastrandr=-1                            local
  117.     int         currandr=0                              local
  118.     int         start=1                                 local
  119.     int         tauntchan=0                             local
  120.     int         killflag=0                              local
  121.     int         firsttime=1                             local
  122.     
  123.     sound        pow=imp2_activate.wav                    local    # Autoloaded
  124.     sound       deadturner=mus_inf_turnerdead.wav       local    
  125.  
  126.     flex        fadeout                                 local
  127.     flex        fadein                                  local
  128.     int         meshindex                               local
  129.     int         boomscreen=0                            local
  130.     int         aieventscreen=0                         local
  131.     flex        n_eventtype                             local
  132.     flex        n_param                                 local
  133.     int         killblock=0                             local
  134.     
  135. end
  136.  
  137. code
  138.  
  139. #........................................................................................
  140.  
  141. startup:
  142.  
  143.     player = GetLocalPlayerThing();
  144.     ClearThingFlags(turner, 0x80000);
  145.     SetThingMesh(turner, 8, mod_tu_imp2, 0);
  146.     CaptureThing(turner);
  147.     call fadeout;
  148.     
  149. return;
  150.  
  151. #........................................................................................
  152.  
  153. damaged:
  154.  
  155.     if ((GetSenderRef() == turner) && (GetParam(1) == 0x04) && (boomscreen == 0))
  156.     {
  157.         //print("turner is in range of explosion");
  158.         boomscreen = 1;
  159.         returnex(0);
  160.         call fadeout;
  161.         modenum = 3;
  162.         KillTimerEx(2);
  163.         SetTimerEX(RandBetween(2, 4), 2, 0, 0);
  164.     }
  165.     
  166. return;
  167.  
  168. #........................................................................................
  169.         
  170. aievent:
  171.  
  172.     //print("aievent received");
  173.     n_eventType = GetParam(0);
  174.     n_param = GetParam(2);
  175.  
  176.     if (n_eventType == 0x1000)        #---- EVENT_TARGETED
  177.     {
  178.         if ((BITTEST(GetWeaponFlags(n_param), 0x20000)) && (aieventscreen == 0))
  179.         {
  180.             aieventscreen = 1;
  181.             call fadeout;
  182.             modenum = 3;
  183.             KillTimerEx(2);
  184.             SetTimerEX(RandBetween(2, 4), 2, 0, 0);    
  185.         }
  186.     }
  187.  
  188. return;
  189.  
  190. #........................................................................................
  191.  
  192. user0:
  193.  
  194.     start = 1;
  195.     SetTimerEX(RandBetween(2, 4), 2, 0, 0);
  196.     
  197. return;
  198.     
  199. #........................................................................................
  200.  
  201. timer:
  202.  
  203.     if (start == 1)
  204.     {
  205.     
  206.         
  207.         //fade turner out
  208.         If (firsttime != 1)
  209.         {
  210.             call fadeout;
  211.             Sleep(2);
  212.         }    
  213.         firsttime = 0;
  214.         
  215.         //throw a rand between 0 and 3
  216.         modenum = RandBetween(0, 3);
  217.         //# print("modenum is");
  218.         //printint(modenum);
  219.         
  220.         //combat mode
  221.         if (modenum == 0)
  222.         {
  223.             //enter combat mode
  224.             # print("combat mode");
  225.             
  226.             //find the closest point to indy and use the next point
  227.             player_curpos = GetThingPos(player);
  228.             
  229.             cur_smallest=VectorDist(player_curpos, GetThingPos(dmatpoint0[0]));
  230.             cur_smallest=abs(cur_smallest);
  231.             
  232.             For (arraycount=1; arraycount<=63; arraycount=arraycount+1)
  233.             {
  234.                 next_smallest = VectorDist(player_curpos, GetThingPos(dmatpoint0[arraycount]));
  235.                 next_smallest=abs(next_smallest);
  236.                 
  237.                 if (cur_smallest > next_smallest)
  238.                 {
  239.                     loc_index = arraycount;
  240.                     cur_smallest = next_smallest;
  241.                 }
  242.             }    
  243.             loc_index=loc_index + (RandBetween(1, 3));
  244.             if (loc_index > 63)
  245.             {
  246.                 loc_index = 63;
  247.             }    
  248.                 
  249.             //materialise turner close to indy and start shooting
  250.             TeleportThing(turner, dmatpoint0[loc_index]);
  251.             Sleep(0.25);
  252.             call fadein;
  253.             Sleep(1.5);
  254.             SetTimerEX(RandBetween(1, 3), 2, 0, 0);
  255.             boomscreen=0;
  256.             aieventscreen=0;
  257.         }
  258.         
  259.         //combat mode
  260.         if (modenum == 1)
  261.         {
  262.             //enter combat mode
  263.             //print("combat mode");
  264.             
  265.             //find the closest point to indy and use the next point
  266.             player_curpos = GetThingPos(player);
  267.             
  268.             cur_smallest=VectorDist(player_curpos, GetThingPos(dmatpoint0[0]));
  269.             cur_smallest=abs(cur_smallest);
  270.             
  271.             For (arraycount=1; arraycount<=63; arraycount=arraycount+1)
  272.             {
  273.                 next_smallest = VectorDist(player_curpos, GetThingPos(dmatpoint0[arraycount]));
  274.                 next_smallest=abs(next_smallest);
  275.                 
  276.                 if (cur_smallest > next_smallest)
  277.                 {
  278.                     loc_index = arraycount;
  279.                     cur_smallest = next_smallest;
  280.                 }
  281.             }    
  282.             loc_index=loc_index + (RandBetween(1, 3));
  283.             if (loc_index > 63)
  284.             {
  285.                 loc_index = 63;
  286.             }
  287.                 
  288.             //materialise turner close to indy and start shooting
  289.             TeleportThing(turner, dmatpoint0[loc_index]);
  290.             Sleep(0.25);
  291.             call fadein;
  292.             Sleep(1.5);
  293.             SetTimerEX(RandBetween(1, 3), 2, 0, 0);
  294.             boomscreen=0;
  295.             aieventscreen=0;
  296.         }
  297.         
  298.         //tauntmode
  299.         if (modenum == 2)
  300.         {
  301.             //tauntmode
  302.             //print("taunting");
  303.             currandt = RandBetween(0, 4);
  304.             While (lastrandt == currandt)
  305.             {
  306.                 currandt = RandBetween(0, 4);
  307.             }
  308.             //tauntchan=PlaySoundThing(tu_line0[currandt], dmatpoint0[RandBetween(0, 63)], 1, 20, 60, 0);
  309.             tauntchan=PlayVoice(turner, tu_line0[currandt], 1, 0);
  310.             WaitForSound(tauntchan);
  311.             lastrandt = currandt;
  312.             SetTimerEX(RandBetween(1, 3), 2, 0, 0);
  313.             boomscreen=0;
  314.             aieventscreen=0;
  315.         }
  316.         
  317.         //random teleportation mode
  318.         if (modenum == 3)
  319.         {
  320.             //random teleport mode
  321.             //print("random teleport");
  322.             currandr = RandBetween(0, 63);
  323.             While (lastrandr == currandr)
  324.             {
  325.                 currandr = RandBetween(0, 63);
  326.             }
  327.             TeleportThing(turner, dmatpoint0[currandr]);
  328.             lastrandr = currandr;
  329.             Sleep(0.25);
  330.             call fadein;
  331.             Sleep(1.5);
  332.             SetTimerEX(RandBetween(1, 3), 2, 0, 0);
  333.             boomscreen=0;
  334.             aieventscreen=0;
  335.         }
  336.     
  337.     }            
  338.         
  339. return;
  340.  
  341. #........................................................................................
  342.  
  343. killed:
  344.  
  345.     if (killblock == 1)
  346.     {
  347.         return;
  348.     }
  349.     killblock = 1;
  350.  
  351.     KillTimerEx(2);
  352.     # print("turner has been killed");
  353.     Sleep(1);
  354.     
  355.     call fadein;
  356.     RestoreThingMesh(turner, meshindex);
  357.     //music
  358.     PlaySoundLocal(deadturner, 1, 0, 0x0, 0);
  359.     
  360.     //create the imp2part where he falls
  361.     CreateThing(imp2template, turner);
  362.     start = 0;
  363.     
  364. return;
  365.              
  366. #........................................................................................
  367.  
  368. fadeout:
  369.     
  370.     SetActorFlags(turner, 0x100000);
  371.     ClearThingFlags(turner, 0x4000);
  372.     AISetCutsceneMode(turner);
  373.     ThingFadeAnim(turner, 1.0, 0.0, 1.0, 0);
  374.     MakeFairyDust(turner, GetThingJointPos(turner, 5));
  375.     PlaySoundThing(pow, turner, 1, 10, 20, 0);
  376.     Sleep(0.5);
  377.     MakeFairyDust(turner, GetThingJointPos(turner, 5));
  378.     Sleep(0.5);
  379.     MakeFairyDust(turner, GetThingJointPos(turner, 5));
  380.     SetCollideType(turner, 0);
  381.     SetActorFlags(turner, 0x80000);
  382.  
  383. return;
  384.  
  385. #........................................................................................
  386.  
  387. fadein:
  388.  
  389.     SetActorFlags(turner, 0x8);
  390.     ThingFadeAnim(turner, 0.0, 1.0, 1.0, 0);
  391.     MakeFairyDust(turner, GetThingJointPos(turner, 5));
  392.     PlaySoundThing(pow, turner, 1, 10, 20, 0);
  393.     Sleep(0.5);
  394.     MakeFairyDust(turner, GetThingJointPos(turner, 5));
  395.     Sleep(0.5);
  396.     MakeFairyDust(turner, GetThingJointPos(turner, 5));
  397.     ClearActorFlags(turner, 0x100000);
  398.     ClearActorFlags(turner, 0x8);
  399.     SetThingFlags(turner, 0x4000);
  400.     SetCollideType(turner, 3);
  401.     AIClearCutsceneMode(turner);
  402.     ClearActorFlags(turner, 0x80000);
  403.  
  404. return;
  405.  
  406. #........................................................................................
  407.  
  408. end
  409.